
#include<iostream>
#include<vector>
#include<string>
#include<stack>

using namespace std;
// Definition for a binary tree node.
struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};


TreeNode* convertBiNode(TreeNode* root) {
    TreeNode *head = new TreeNode(-1);
    TreeNode *res = head;
    stack<TreeNode*> stk;
    while(!stk.empty() || root) {
        while(root == NULL) {
            stk.push(root);
            root = root->left;
        }
        root = stk.top();
        stk.pop();
        root->left = NULL;
        res->right = root;
        res = root;
        root = root->right;
    }
    return head->right;

}
int main() {
    TreeNode *head = new TreeNode(-1);
    TreeNode *res = head;
}